package cbm.commons;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;

public class ForwardController extends MultiActionController{
	
	  private static Logger logger = Logger.getLogger(ForwardController.class);
	  private ViewHelper viewHelper = ViewHelper.getInstance();

	  public ForwardController(){
	    super();
	    logger.debug("[ForwardController]");
	  }
	  
	  public ModelAndView redirect(HttpServletRequest request, HttpServletResponse response){
	    String page =  null;
	    
	    try{
	    String aux = request.getParameter("page");
	    System.out.print("redirect to " + aux);
	    page = viewHelper.getResource(request.getParameter("page"));
	    System.out.println(page);
	    logger.debug("[redirect to "+page+" ]");
	    
	    }catch(Exception e){
	      e.printStackTrace();
	    }
	    return new ModelAndView(page);
	  }
}
